package com.gk.study.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gk.study.mapper.RoomWishMapper;
import com.gk.study.service.RoomWishService;
import com.gk.study.entity.RoomWish;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
class RoomWishServiceImpl extends ServiceImpl<RoomWishMapper, RoomWish> implements RoomWishService {
    @Autowired
    RoomWishMapper mapper;

    @Override
    public List<Map> getRoomWishList(String userId) {
        return mapper.getRoomWishList(userId);
    }

    @Override
    public void createRoomWish(RoomWish roomWish) {
        mapper.insert(roomWish);;
    }

    @Override
    public void deleteRoomWish(String id) {
        mapper.deleteById(id);
    }

    @Override
    public RoomWish getRoomWish(String userId, String roomId) {
        QueryWrapper<RoomWish> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("room_id", roomId)
                .eq("user_id", userId);
        return mapper.selectOne(queryWrapper);
    }
}
